﻿using GrapeCity.Forguncy.Commands;
using GrapeCity.Forguncy.Plugin;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PlugGraphVisVue
{

    /// <summary>
    /// 画布工具条显示配置
    /// </summary>
    public class ToolBarShowConfig : ObjectPropertyBase
    {

        [DisplayName("顶部工具条")]
        [Description("放大、原始大小、缩小、窗口内显示、框选、自由框选、常规模式")]
        [BoolProperty(IndentLevel =2)]
        [DefaultValue(true)]
        public bool toolbar_top { get; set; } = true;

        [DisplayName("顶部搜索框")]
        [Description("")]
        [BoolProperty(IndentLevel = 2)]
        [DefaultValue(true)]
        public bool toolbar_search { get; set; } = true;

        [DisplayName("右侧工具条")]
        [Description("图谱信息、节点连线配置、布局、路径、分析重点对象、划分群组、共同关联分析")]
        [BoolProperty(IndentLevel = 2)]
        [DefaultValue(true)]
        public bool toolbar_right { get; set; } = true;

        [DisplayName("底部工具条")]
        [Description("底部工具条，分左边、右边。")]
        [BoolProperty(IndentLevel = 2)]
        [DefaultValue(true)]
        public bool toolbar_bottom { get; set; } = true;

        [DisplayName("底部左边工具条")]
        [Description("分析历史、实体、关系、下载")]
        [BoolProperty(IndentLevel = 2)]
        [DefaultValue(true)]
        public bool toolbar_bottom_left { get; set; } = true;

        [DisplayName("底部右边工具条")]
        [Description("增加间距、缩小间距、顺时针旋转、逆时针旋转")]
        [BoolProperty(IndentLevel = 2)]
        [DefaultValue(true)]
        public bool toolbar_bottom_right { get; set; } = true;
    }
        /// <summary>
        /// 下载图片水印设置
        /// </summary>
        public class TextWatermark : ObjectPropertyBase
    {

        [DisplayName("保存文件名前缀")]
        public string fileName { get; set; } = "数据可视化";

        [DisplayName("是否需要水印")]
        [Description("打勾，下面的配置才起作用。")]
        [BoolProperty]
        [DefaultValue(false)]
        public bool needWatermark { get; set; } =false;

        [DisplayName("水印文字")]
        public string content { get; set; } = "数据可视化";
        [DisplayName("倾斜角度")]
        [IntProperty(AllowNull = false, Watermark = "",Min =-90,Max =90)]
        [Required]
        public int angle { get; set; } = -30;
        [DisplayName("透明度")]
        [DoubleProperty(AllowNull = false, Watermark = "", Min = 0, Max = 0.99)]
        [Required]
        public double alpha { get; set; } =0.2;

        [DisplayName("字体样式")]
        [RadioGroupProperty(ValueList = "normal|italic|bold ", DisplayList = "正规|斜体|加粗")]
        public string fontStyle { get; set; } = "normal";

        [DisplayName("字体大小")]
        [IntProperty(AllowNull = false, Watermark = "")]
        [Required]
        public int fontSize { get; set; } = 60;

        [DisplayName("字体名称")]
        [Required]
        [FontFamilyProperty]
        public string fontFamliy { get; set; }

        [DisplayName("文字颜色")]
        [ColorProperty(SupportTranslucency = false, SupportNoFill = true)]
        public string fontColor { get; set; }

    }
    public class Font : ObjectPropertyBase
    {
        [DisplayName("字体样式")]
        [RadioGroupProperty(ValueList = "normal|italic|oblique ", DisplayList = "正规|斜体|倾斜")]
        public string font_style { get; set; } = "normal";

        [DisplayName("字体大小")]
        [IntProperty(AllowNull = false, Watermark = "")]
        [Required]
        public int font_size { get; set; } = 12;

        [DisplayName("字体名称")]
        [Required]
        [FontFamilyProperty]
        public string font_family { get; set; }
        public override string ToString()
        {
            return font_style + " " + font_size.ToString() + "px" + font_family;
        }

    }
    public class TreeNode : ObjectPropertyBase
    {
        [Description("节点唯一性标识，不可重复")]
        [Required]
        [Key]
        public string id { get; set; }

        [Description("父节点ID")]
        public string pid { get; set; }

        [Description("节点显示文字名称")]
        [Required]
        public string label { get; set; }

        [Description("节点分类类型，如：人、事、物、地、案件等类型定义值")]
        [Required]
        public string type { get; set; }

        [Description("节点样式属性定义，一般是节点个性化的样式数据设置，会覆盖统一配置的样式")]
        [DisplayName("节点样式属性")]
        [ObjectProperty(ObjType = typeof(NodeStyle))]
        public NodeStyle style { get; set; }

        [Description("节点的业务属性，业务应用需要附加在节点上的额外信息，用于业务交互处理")]
        [DisplayName("节点业务属性")]
        [ObjectProperty(ObjType = typeof(BusinessProperties))]
        public BusinessProperties properties { get; set; }



    }

    public class BusinessProperties : ObjectPropertyBase
    {
        [DisplayName("业务属性1")]
        public string Properties01 { get; set; }


        [DisplayName("业务属性2")]
        public string Properties02 { get; set; }

        [DisplayName("业务属性3")]
        public string Properties03 { get; set; }

    }

    public class NodeStyle : ObjectPropertyBase
    {
        [DisplayName("X坐标值")]
        [IntProperty(AllowNull =true)]
        [Description("一般不填写")]
        public int? x { get; set; }


        [DisplayName("Y坐标值")]
        [Description("一般不填写")]
        [IntProperty(AllowNull = true)]
        public int? y { get; set; }

        [DisplayName("形状")]
        [ComboProperty(ValueList = "circle|polygon|square|star", DisplayList = "圆形 |六边形 |正方形 |星形")]
        public string shape { get; set; }

        [DisplayName("大小")]
        [IntProperty(AllowNull = true)]
        public int? size { get; set; }

        [DisplayName("是否显示")]
        [BoolProperty(IndentLevel = 0)]
        [DefaultValue(true)]
        public bool visible { get; set; } = true;

        [DisplayName("是否显示名称")]
        [BoolProperty(IndentLevel = 0)]
        [DefaultValue(true)]
        public bool showlabel { get; set; } = true;

        [DisplayName("节点颜色")]
        [ColorProperty(SupportTranslucency = false, SupportNoFill = true)]
        public string fillColor { get; set; }

        [DisplayName("边框宽度")]
        [IntProperty(AllowNull = true)]
        public int? borderWidth { get; set; }

        [DisplayName("边框颜色")]
        [ColorProperty(SupportTranslucency = false, SupportNoFill = true)]
        public string borderColor { get; set; }


        [DisplayName("选中时边框宽度")]
        [IntProperty(AllowNull = true)]
        public int? selectedBorderWidth { get; set; }

        [DisplayName("选中时边框颜色")]
        [ColorProperty(SupportTranslucency = false, SupportNoFill = true)]
        public string selectedBorderColor { get; set; }

        [DisplayName("是否显示阴影")]
        [BoolProperty(IndentLevel = 0)]
        [DefaultValue(true)]
        public bool showShadow { get; set; } = true;


        [DisplayName("阴影的范围大小")]
        [IntProperty(AllowNull = true)]
        public int? shadowBlur { get; set; }

        [DisplayName("阴影的颜色")]
        [ColorProperty(SupportTranslucency = false, SupportNoFill = true)]
        public string shadowColor { get; set; }

        [DisplayName("字体")]
        [ObjectProperty(ObjType = typeof(Font))]
        public Font font { get; set; }


        [DisplayName("字体颜色")]
        [ColorProperty(SupportTranslucency = false, SupportNoFill = true)]
        public string fontColor { get; set; }


        [DisplayName("文字位置")]
        [ComboProperty(ValueList = "Middle_Center|Bottom_Center|Top_Center" , DisplayList = "居中|下居中|上居中")]
        public string textPosition { get; set; }


        [DisplayName("图片路径")]
        [Description("图片的url路径")]
        public string image { get; set; }

        [DisplayName("角标的颜色")]
        [ColorProperty(SupportTranslucency = false, SupportNoFill = true)]
        public string tagColor { get; set; }

        [DisplayName("角标的值")]
        [Description("逗号分割,如:朋友,同学，夫妻")]
        public string tags { get; set; }
    }


    public  class Link : ObjectPropertyBase
    {
        [DisplayName("连线ID")]
        [Description("连线的唯一性标识，不可重复")]
        [Key]
        [Required]
        public string id { get; set; }

        [DisplayName("起始节点ID")]
        [Description("起始节点ID")]
        [Required]
        public string source { get; set; }

        [DisplayName("目标节点ID")]
        [Description("目标节点ID")]
        [Required]
        public string target { get; set; }

        [DisplayName("连线名称")]
        [Description("连线显示的关系名称")]
        public string label { get; set; }

        [DisplayName("连线业务类型")]
        [Description("连线业务类型，\r\n如：通话、亲人、朋友、同住、同行等类型定义值")]
        public string type { get; set; }


        [DisplayName("连线属性定义")]
        [Description("连线属性定义，\r\n一般是连线个性化的样式数据设置，会覆盖统一配置的样式")]
        [ObjectProperty(ObjType = typeof(LinkStyle))]
        public LinkStyle style { get; set; }

        [Description("连线的业务属性，\r\n业务应用需要附加在连线上的额外信息，用于业务交互处理")]
        [DisplayName("节点业务属性")]
        [ObjectProperty(ObjType = typeof(BusinessProperties))]
        public BusinessProperties properties { get; set; }
    }


    public class SingleNodeStyle : ObjectPropertyBase, INamedObject
    {
        public string Name { get; set; }

        [BindingDataSourceProperty(Columns = "nodeid", ColumnsDescription = "nodeid:唯一节点ID", IndentLevel = 0)]
        [DisplayName("筛选节点")]
        [Description("从数据库查询符合条件的节点")]
        public object FilterFromDB_Node { get; set; }


        [DisplayName("节点样式")]
        [Description("筛选的节点，都应用此样式")]
        [ObjectProperty(ObjType = typeof(NodeStyle))]
        public NodeStyle NodeStyleConfig { get; set; }
    }

    public class SingleLinkStyle : ObjectPropertyBase, INamedObject
    {
        public string Name { get; set; }

        [BindingDataSourceProperty(Columns = "linkid", ColumnsDescription = "linkid:唯一连线ID", IndentLevel = 0)]
        [DisplayName("筛选连线")]
        [Description("从数据库查询符合条件的连线")]
        public object FilterFromDB_Link { get; set; }


        [DisplayName("连线样式")]
        [Description("筛选的连线，都应用此样式")]
        [ObjectProperty(ObjType = typeof(LinkStyle))]
        public LinkStyle LinkStyleConfig { get; set; }
    }

    public class LinkStyle : ObjectPropertyBase
    {
 

        [DisplayName("连线类型")]
        [ComboProperty(ValueList = "straight|hlink|vlink|hbezier|vbezier", DisplayList = "直线 |横向折线 |竖向折线 |横向贝塞尔曲线|竖向贝塞尔曲线")]
        public string lineType { get; set; }

        [DisplayName("连线的宽度")]
        [IntProperty(AllowNull = true)]
        public int? lineWidth { get; set; }

        [DisplayName("是否显示")]
        [BoolProperty(IndentLevel = 0)]
        [DefaultValue(true)]
        public bool visible { get; set; } = true;

        [DisplayName("是否显示名称")]
        [BoolProperty(IndentLevel = 0)]
        [DefaultValue(true)]
        public bool showlabel { get; set; } = true;

        [DisplayName("是否显示箭头")]
        [BoolProperty(IndentLevel = 0)]
        [DefaultValue(true)]
        public bool showArrow { get; set; } = true;

        [DisplayName("箭头类型")]
        [ComboProperty(ValueList = "arrow|triangle", DisplayList = "箭头|三角形")]
        public string arrowType { get; set; }


        [DisplayName("连线颜色")]
        [ColorProperty(SupportTranslucency = false, SupportNoFill = true)]
        public string strokeColor { get; set; }

        [DisplayName("连线文字背景颜色")]
        [ColorProperty(SupportTranslucency = false, SupportNoFill = true)]
        public string labelBackGround { get; set; }

        [DisplayName("选中时的颜色")]
        [ColorProperty(SupportTranslucency = false, SupportNoFill = true)]
        public string selectedColor { get; set; }

        [DisplayName("连线背景色")]
        [ColorProperty(SupportTranslucency = false, SupportNoFill = true)]
        public string background { get; set; }

        [DisplayName("字体")]
        [ObjectProperty(ObjType = typeof(Font))]
        public Font font { get; set; }


        [DisplayName("字体颜色")]
        [ColorProperty(SupportTranslucency = false, SupportNoFill = true)]
        public string fontColor { get; set; }
         

        [DisplayName("虚线间隔")]
        [Description("连线虚线间隔,逗号分割,如:3,5")]
        public string lineDash { get; set; }
    }

    //-----------------------------------------------------------
    #region  全局配置
    public class GlobalConfig : ObjectPropertyBase
    {
        [Description("")]
        [DisplayName("节点的默认配置")]
        [ObjectProperty(ObjType = typeof(GlobalConfig_Node))]
        public GlobalConfig_Node node { get; set; }



        [Description("")]
        [DisplayName("连线的默认配置")]
        [ObjectProperty(ObjType = typeof(GlobalConfig_Link))]
        public GlobalConfig_Link link { get; set; }


        [DisplayName("相邻节点高度标志")]
        [BoolProperty(IndentLevel = 0)]
        [DefaultValue(true)]
        public bool highLightNeiber { get; set; } = true;


        [DisplayName("滚轮缩放")]
        [Description("滚轮缩放开关，不使用时不设置")]

        [DoubleProperty(AllowNull = true, Watermark = "", Min = 0, Max = 1)]
        public double? wheelZoom { get; set; }

        [Description("")]
        [DisplayName("框选区域的颜色配置")]
        [ObjectProperty(ObjType = typeof(GlobalConfig_SelectBox))]
        public GlobalConfig_SelectBox selectBox { get; set; }
    }
    public class GlobalConfig_Node : ObjectPropertyBase
    {
        [Description("")]
        [DisplayName("标签配置")]
        [ObjectProperty(ObjType = typeof(GlobalConfig_Node_Label))]
        public GlobalConfig_Node_Label label { get; set; }

        [DisplayName("形状")]
        [ComboProperty(ValueList = "circle|polygon|square|star|rect", DisplayList = "圆形 |六边形 |正方形 |星形|矩形")]
        public string shape { get; set; } = "circle";

        [DisplayName("节点半径大小")]
        [IntProperty(AllowNull = true)]
        public int? size { get; set; } = 60;

        [DisplayName("矩形宽")]
        [Description("矩形使用")]
        [IntProperty(AllowNull = true)]
        public int? width { get; set; } = 80;  
        
        [DisplayName("矩形高")]
        [Description("矩形使用")]
        [IntProperty(AllowNull = true)]
        public int? height { get; set; } = 60;

        [DisplayName("节点颜色")]
        [ColorProperty(SupportTranslucency = false, SupportNoFill = true)]
        public string color { get; set; }

        [DisplayName("边框颜色")]
        [ColorProperty(SupportTranslucency = false, SupportNoFill = true)]
        public string borderColor { get; set; }

        [DisplayName("边框宽度")]

        public int borderWidth { get; set; } = 0;

        [DisplayName("角标的颜色")]
        [ColorProperty(SupportTranslucency = false, SupportNoFill = true)]
        public string tagColor { get; set; }

    }

    public class GlobalConfig_Node_Label : ObjectPropertyBase
    {
        [DisplayName("是否显示")]
        [Description("")]
        [BoolProperty(IndentLevel = 0)]
        [DefaultValue(true)]
        public bool show { get; set; } = true;

        [DisplayName("字体颜色")]
        [ColorProperty(SupportTranslucency = false, SupportNoFill = true)]
        public string color { get; set; }


        [DisplayName("字体")]
        [ObjectProperty(ObjType = typeof(Font))]
        public Font font { get; set; }


        [DisplayName("文字位置")]
        [ComboProperty(ValueList = "Middle_Center|Bottom_Center|Top_Center", DisplayList = "居中|下居中|上居中")]
        public string textPosition { get; set; }

        [DisplayName("文字横向偏移量")]

        [IntProperty(AllowNull = true, Watermark = "")]
        public int? textOffsetX { get; set; }


        [DisplayName("文字纵向偏移量")]

        [IntProperty(AllowNull = true, Watermark = "")]
        public int? textOffsetY { get; set; }

        [DisplayName("文字背景色")]
        [ColorProperty(SupportTranslucency = false, SupportNoFill = true)]
        public string background { get; set; }

    }
    public class GlobalConfig_Node_Selected : ObjectPropertyBase
    {

    }
    public class GlobalConfig_Link : ObjectPropertyBase
    {
        [Description("")]
        [DisplayName("连线标签")]
        [ObjectProperty(ObjType = typeof(GlobalConfig_Link_Label))]
        public GlobalConfig_Link_Label label { get; set; }

 

        [DisplayName("连线类型")]
        [ComboProperty(ValueList = "straight|hlink|vlink|hbezier|vbezier", DisplayList = "直线 |横向折线 |竖向折线 |横向贝塞尔曲线|竖向贝塞尔曲线")]
        public string lineType { get; set; } = "straight";

        [DisplayName("连线颜色")]
        [ColorProperty(SupportTranslucency = false, SupportNoFill = true)]
        public string color { get; set; }

        [DisplayName("连线的宽度")]
        [IntProperty(AllowNull = true)]
        public int? lineWidth { get; set; } = 2;



        [DisplayName("显示连线箭头")]
        [BoolProperty(IndentLevel = 0)]
        [DefaultValue(true)]
        public bool showArrow { get; set; } = true;

        [DisplayName("箭头类型")]
        [ComboProperty(ValueList = "arrow|triangle", DisplayList = "箭头|三角形")]
        public string arrowType { get; set; }

        [Description("")]
        [DisplayName("选中时的样式设置")]
        [ObjectProperty(ObjType = typeof(GlobalConfig_Link_Selected))]
        public GlobalConfig_Link_Selected selected { get; set; }



    }
    public class GlobalConfig_Link_Label : ObjectPropertyBase
    {
        [DisplayName("是否显示")]
        [Description("")]
        [BoolProperty(IndentLevel = 0)]
        [DefaultValue(true)]
        public bool show { get; set; } = true;

        [DisplayName("字体颜色")]
        [ColorProperty(SupportTranslucency = false, SupportNoFill = true)]
        public string color { get; set; }

        [DisplayName("字体")]
        [ObjectProperty(ObjType = typeof(Font))]
        public Font font { get; set; }



        [DisplayName("文字背景色")]
        [Description("文字背景色(有背景时上线居中)")]
        [ColorProperty(SupportTranslucency = false, SupportNoFill = true)]
        public string background { get; set; }
    }
    public class GlobalConfig_Link_Selected : ObjectPropertyBase
    {
        [DisplayName("选中时的颜色")]
        [ColorProperty(SupportTranslucency = false, SupportNoFill = true)]
        public string color { get; set; }
    }

    public class GlobalConfig_SelectBox : ObjectPropertyBase
    {
        [DisplayName("框的颜色")]
        [ColorProperty(SupportTranslucency = false, SupportNoFill = true)]
        public string color { get; set; }

        [DisplayName("框的透明度")]

        [DoubleProperty(AllowNull = true, Watermark = "",Min =0,Max =1)]
        public double? alpha { get; set; }
    }

    #endregion
    //----------------------------------------------------------

    public class NodeRightClick : ObjectPropertyBase
    {
        [DisplayName("节点右键文本")]
        public string NodeRightClickText { get; set; }


        [CustomCommandObject(InitParamProperties = "node_id|node_label", InitParamValues = "节点ID|节点标签文本",
            ParameterDescriptions = "node_id:节点ID|node_label:节点标签文本")]
        [DisplayName("节点右键执行命令")]
        public object NodeRightClickCommand { get; set; }
    }

    public class LinkRightClick : ObjectPropertyBase
    {
        [DisplayName("节点右键文本")]
        public string LinkRightClickText { get; set; }


        [CustomCommandObject(InitParamProperties = "link_id|link_label|link_source|link_target", InitParamValues = "连线ID|连线标签文本|连线源节点ID|连线目标节点ID",
            ParameterDescriptions = "link_id:连线ID|link_label:连线标签文本|link_source:连线源节点ID|link_target:连线目标节点ID")]
        [DisplayName("节点右键执行命令")]
        public object LinkRightClickCommand { get; set; }
    }
}
